import simplejson as json

import EventInfo

def event_info_to_json(event_info):
    if not event_info:
        return {"event":"", "locations":{}}
    else:
        return {"event":(event_info.event).encode("utf-8"),
				"locations":dict(event_info.event_locations)}

#===================================================================

def event_infos_to_json(event_infos):
    if not event_infos:
        return {"event_infos":[] }		
    else:
        return {"event_infos":map(event_info_to_json, event_infos)}

#===================================================================

def dump_event_infos(event_infos):
    json_output = event_infos_to_json(event_infos)
    
    print unicodedata.normalize("NFC", \
                                (json.dumps(json_output,
                                            ensure_ascii=False, 
                                            indent=4,
                                            encoding="utf-8")))

#===================================================================
